package main

import (
	_ "embed"

	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/app"
	"fyne.io/fyne/v2/container"
	"fyne.io/fyne/v2/layout"
	"fyne.io/fyne/v2/widget"
	"github.com/zhaocy/fyne-theme"
)

//go:embed fyne.png
var icon []byte

func main() {
	myApp := app.NewWithID("icon-demo")
	myApp.Settings().SetTheme(themex.Themex())
	myWin := myApp.NewWindow("Icon")

	// 静态资源的icon
	sr := fyne.NewStaticResource("myicon", icon)
	// 创建一个icon
	icon1 := widget.NewIcon(sr)

	// 创建一个fyne自带的icon
	icon2 := widget.NewFileIcon(nil)
	icon2.SetURI(myApp.Storage().RootURI())

	icons := container.NewHBox(
		icon1,
		icon2,
	)
	//设置窗口的icon (macos没有)
	myWin.SetIcon(sr)

	// button with icon
	btn := widget.NewButtonWithIcon("我有图标", sr, nil)
	btnBox:= container.NewHBox(btn,layout.NewSpacer())

	myWin.SetContent(container.NewVBox(icons, btnBox))
	myWin.Resize(fyne.NewSize(550, 450))
	myWin.ShowAndRun()
}
